home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 6582 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. Path: newshost.lanl.gov!tanmoy
  2. From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Function pointers; example code
  5. Date: 18 Feb 1996 18:20:49 GMT
  6. Organization: Los Alamos National Laboratory
  7. Message-ID: <TANMOY.96Feb18112049@qcd.lanl.gov>
  8. References: <DMwzBL.HDt@ichaos.nullnet.fi>
  9. NNTP-Posting-Host: qcd.lanl.gov
  10. Mime-Version: 1.0
  11. Content-Type: text
  12. In-reply-to: jlaiho@ichaos.nullnet.fi's message of Sat, 17 Feb 1996 09:50:09 GMT
  13.  
  14. In article <DMwzBL.HDt@ichaos.nullnet.fi> jlaiho@ichaos.nullnet.fi
  15. (Juha Laiho) writes: 
  16. <snip>
  17.    Here's a short program I wrote as an example of function pointers. I'd
  18.    appreciate _any_ comments about it.
  19.  
  20.    ---SNIP---
  21.    #include <stdio.h>
  22.  
  23.    typedef void f(int); /* f is a type that is a function taking one int
  24.              * argument and returning an int
  25.              */
  26.  
  27. Pointless and incorrect comment!
  28.  
  29.    typedef f *ptf;      /* ptf is a type that is a pointer to a function */
  30.  
  31. ptf is a pointer to a specific kind of function.
  32.  
  33.    typedef ptf aptf[];  /* aptf is a type that is an array of ptfs */
  34.  
  35.    f a, b, c; /* Define three functions a, b and c; each is 'void f(int)' */
  36.  
  37.    int
  38.    main ()
  39.  
  40. int main(void) is preferred stylistically over int main(). 
  41.  
  42. Quick glance at the rest shows no obvious mistake.
  43.  
  44. Cheers
  45. Tanmoy
  46. --
  47. tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
  48. Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
  49. Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
  50. <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
  51. internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
  52. fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
  53.